//////////////////////////////////////////////////////////////////
// MattiseOS Kernel
// Date: 2008
// Author: Matthew Iselin
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
//////////////////////////////////////////////////////////////////

// Defines
#ifndef PAGE_H
#define PAGE_H

// Includes
#include <mattise.h>
#include <stdint.h>

// Prototypes

// allocates contiguous space and maps it in
uint32_t kAllocateAndMap( uint32_t count, uint32_t vaddr, uint32_t flags );

// allocates contiguous space and maps it in to a specific page dir
uint32_t kAllocateAndMapPageDir( uint32_t pagedir, uint32_t count, uint32_t vaddr, uint32_t flags );

// allocates contiguous space and maps it into two seperate address spaces
uint32_t kAllocateAndMapPageDirTwice( uint32_t pagedir1, uint32_t pagedir2, uint32_t count, uint32_t vaddr1, uint32_t vaddr2, uint32_t flags1, uint32_t flags2 );

// frees pages mapped with the previous functions
void kFreeMappedPages( uint32_t count, uint32_t vaddr );

// allocates one or more contiguous pages
uint32_t* kAllocatePages( uint32_t count );

// frees pages starting at a specific address
void kFreePages( uint32_t* addr );

// sets a set of pages to either on or off
void kSetPages( uint32_t start, uint32_t end, uint32_t set );

// sets up the page allocator
void kInitPageAlloc( uint32_t maxmem );

// finds out how much memory is available
uint32_t kGetAvailMem();

#endif
